<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <!-- 遍历数组 -->
        <h1>人员列表</h1>
        <ul>
            <li v-for="(value,index) in persons" :key="value.id">
                {{value.name}}-{{value.age}}
            </li>
        </ul>
        <hr>

        <!-- 遍历对象 -->
        <h1>英雄列表</h1>
        <ul>
            <li v-for="(value, key,index) in hero" :key="key">
                {{value}}-{{key}}-{{index}}
            </li>
        </ul>
        <hr>

        <!-- 遍历字符串 -->
        <h1>遍历字符串</h1>
        <div v-for="(value, index) in str" :key="index">
            {{value}}-{{index}}
        </div>
        <hr>

        <!-- 遍历指定次数 -->
        <h1>遍历指定次数</h1>
        <div v-for="(value, index) in 5">
            {{value}}-{{index}}
        </div>

    </div>
    <script>
        Vue.config.productionTip = false //取消生产提示

        const vm = new Vue({
            el: '#root',
            data() {
                return {
                    persons: [{
                            id: '001',
                            name: '张三',
                            age: 18
                        },
                        {
                            id: '002',
                            name: '李四',
                            age: 19
                        },
                        {
                            id: '003',
                            name: '王五',
                            age: 20
                        },
                    ],
                    hero: {
                        heroName: '疾风剑豪',
                        prcie: 6300,
                        skin: '黑夜使者'
                    },
                    str: 'hello'
                }
            }
        })
    </script>
</body>

</html>